package com.zhou.common.mybatis.template.shiro.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.zhou.common.lib.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum PolicyStatusEnum implements BaseEnum<String> {

    /**
     *
     */
    DRAFT("DRAFT1", "草稿状态"),
    AUDIT_WAIT("AUDIT_WAIT", "待审核"),
    PUBLISH_WAIT("PUBLISH_WAIT", "待发布"),
    PUBLISHED("PUBLISHED", "已发布"),
    UN_PASSED("UN_PASSED", "未通过"),
    OFF_THE_SHELF("OFF_THE_SHELF", "下架");

    @EnumValue
    @JsonValue
    private String value;
    private String text;

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static PolicyStatusEnum getItem(String code) {
        for (PolicyStatusEnum item : values()) {
            if (item.getValue().equals(code)) {
                return item;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return String.format("%s-%s", value, text);
    }

    @Override
    public String getCode() {
        return value;
    }
}
